import comfirm from '@/components/comfirm.vue';
import payforBill from '@/pages/members/payforBill/payforBill.vue';
import {timestampToTime} from '@/util/util';

export default {
  name:'billDetail',
  data:() => ({
    billDetail:'',
    detailList:[],
    contractId:'',    //合同id
    comfirmTitle:{
      comfirmTop:'支付失败',
      comfirmCon:'支付遇到问题，请尝试重新支付',
      comfirmBtn:['取消','重新支付'],
    },
    isWrong:false,
    popupVisible:false,
    rentMoney:0,    //租金
    monthNum:0,   //月数
  }),
  components:{
    comfirm,
    payforBill,
  },
  computed:{
    // 账单状态
    billState:function () {
      var state = this.billDetail.payState;
      switch (state) {
        case 1:
          return '待支付';
          break;
        case 2:
          return '已支付';
          break;
        case 4:
          return '支付失败';
          break;
        default:
        break;
      }
    },
    // 租房日期
    rentDate() {
      let startDay = this.billDetail.startDay;    //开始时间
      let endDay = this.billDetail.endDay;        //结束时间
      return timestampToTime(startDay)+'-'+timestampToTime(endDay);
    },
  },
  methods:{
    payBtn(){
      this.popupVisible = true;
    },
    closePayfor() {
      this.popupVisible = false;
    },
    comfirmEvent(data){
      this.isWrong = false;
    }
  },
  mounted() {
    //do something after mounting vue instance

  },
  created() {
    let that = this;
    let billId = that.$route.query.billId;
    that.contractId = that.$route.query.contractId;    //合同id
    let billParam = {
      billId:billId
    }
    network.get(configUrl.USERBILLDETAIL_URL,billParam,function(res){ //获取账单详情
      console.log(res);
      let data = res.data;
      that.billDetail = data;
      that.detailList = data.detailList;
      that.rentMoney = data.detailList[0].rentMoney/100;
      that.monthNum = data.detailList[0].monthNum;
    },function(err){
      console.log(err);
    });
  }
}
